package com.zzxx.wechat.util;

import com.zzxx.wechat.common.ArcterySkuVo;

import java.util.*;

public class SkuComparator implements Comparator<ArcterySkuVo> {
    private static final Map<String, Integer> sizeMap = new HashMap<>();

    static {
        sizeMap.put("XXS", 1);
        sizeMap.put("XS", 2);
        sizeMap.put("S", 3);
        sizeMap.put("M", 4);
        sizeMap.put("L", 5);
        sizeMap.put("XL", 6);
        sizeMap.put("XXL", 7);
        // 添加其他尺码和对应的值  
    }

    @Override
    public int compare(ArcterySkuVo c1, ArcterySkuVo c2) {

        int colourComparison = c1.getColourLabel().compareTo(c2.getColourLabel());
        if (colourComparison == 0) {
            return Integer.compare(sizeMap.get(c1.getSizeLabel()), sizeMap.get(c2.getSizeLabel()));
        }
        return colourComparison;
    }


}